package com.example.perplonews.a_d_fragment.c_video

import BaseFragment
import android.os.Bundle
import android.view.View
import android.widget.LinearLayout
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.example.perplonews.R
import com.example.perplonews.a_a_mvp.contract.News_Contract
import com.example.perplonews.a_a_mvp.model.HttpCode
import com.example.perplonews.a_a_mvp.model.models.News_Model
import com.example.perplonews.a_a_mvp.presenter.presenters.News_Presenter
import com.example.perplonews.a_b_entity.BaseEntity
import com.example.perplonews.a_b_utils.LjlUtils
import com.example.perplonews.a_d_fragment.c_video.adapter.Video_Rec_Adapter
import com.example.perplonews.a_d_fragment.c_video.entity.VideoNewsEntity


class Recom_Fragment : BaseFragment<News_Presenter>(), News_Contract.NewsView {
    private val videoRec: RecyclerView by lazy { findViewById<RecyclerView>(R.id.video_rec) }

    override fun findlayout(): Int {
        return R.layout.fragment_recom_
    }

    override fun initView() {

    }

    override fun initData() {

        mypre = News_Presenter(News_Model(), this)
        var map: HashMap<String, Any> = hashMapOf()
        map.put("news_type",0)
        map["page"] = 1
        map.put("code", HttpCode.VIDEONEWSCODE)


        var list: ArrayList<HashMap<String, Any>> = ArrayList()
        list.add(map)
        mypre.requestAll(list)


    }

    override fun refreshAll(entity: BaseEntity) {
        if (entity is VideoNewsEntity){
            var videoNewsEntity = entity as VideoNewsEntity
            var values = videoNewsEntity.getValues()
            var adapters:Video_Rec_Adapter = Video_Rec_Adapter((values as ArrayList<VideoNewsEntity.Values>))
            videoRec.adapter = adapters
            videoRec.layoutManager = LinearLayoutManager(activity,LinearLayoutManager.VERTICAL,false)
            videoRec.addItemDecoration(DividerItemDecoration(activity,DividerItemDecoration.HORIZONTAL))


        }
    }

    override fun startPage(bundle: Bundle, clazz: Class<Any>) {

    }



}